package com.zone.domain.rebate.service.settle.impl;

import com.zone.domain.acticity.model.entity.ActivityOrderCreateEntity;
import com.zone.domain.acticity.model.valobj.ActivityOrderTraceTypeEnum;
import com.zone.domain.acticity.service.IActivityOrderQuota;
import com.zone.domain.common.factory.FactoryName;
import com.zone.domain.rebate.model.valobj.BehaviorTypeEnum;
import com.zone.domain.rebate.model.valobj.RebateTypeEnum;
import com.zone.domain.rebate.service.settle.IUserBehaviorRebateSettle;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: zongzi
 * @description: TODO
 * @date: 2025/3/3
 */
@Slf4j
@Component
public class SignSkuRebateSettle implements IUserBehaviorRebateSettle, FactoryName {
    @Autowired
    private IActivityOrderQuota activityOrderQuota;

    @Override
    public void execute(String userId, String behaviorType, String rebateType, String rebateConfig) {
        log.info("签到-sku行为返利执行器 userId = {}, behaviorType = {}, rebateType = {}, rebateConfig = {}", userId, behaviorType, rebateType, rebateConfig);
        // 充值活动额度
        Long sku = Long.valueOf(rebateConfig);
        ActivityOrderCreateEntity quotaCreate = ActivityOrderCreateEntity.builder()
                .sku(sku)
                .userId(userId)
                .outBusinessNo(RandomStringUtils.randomNumeric(11))
                .orderTraceTypeEnum(ActivityOrderTraceTypeEnum.NO_PAY)
                .build();
        activityOrderQuota.doOrder(quotaCreate);
    }

    @Override
    public String getName() {
        return String.format("%s_%s", BehaviorTypeEnum.SIGN.getCode(), RebateTypeEnum.SKU.getCode());
    }
}
